/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.anachronos.jeep.model.trace.impl;

import org.anachronos.jeep.model.trace.CallStacksType;
import org.anachronos.jeep.model.trace.MergedMethodInvocationsType;
import org.anachronos.jeep.model.trace.MergedSqlStatementExecutionsType;
import org.anachronos.jeep.model.trace.MethodsType;
import org.anachronos.jeep.model.trace.ThreadCallStack;
import org.anachronos.jeep.model.trace.Trace;
import org.anachronos.jeep.model.trace.TracePackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Trace</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.TraceImpl#getMethods <em>Methods</em>}</li>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.TraceImpl#getCallStacks <em>Call Stacks</em>}</li>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.TraceImpl#getMergedMethodInvocations <em>Merged Method Invocations</em>}</li>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.TraceImpl#getMergedSqlStatementExecutions <em>Merged Sql Statement Executions</em>}</li>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.TraceImpl#getMergedCallStack <em>Merged Call Stack</em>}</li>
 *   <li>{@link org.anachronos.jeep.model.trace.impl.TraceImpl#getRootPackage <em>Root Package</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TraceImpl extends EObjectImpl implements Trace {
	/**
	 * The cached value of the '{@link #getMethods() <em>Methods</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMethods()
	 * @generated
	 * @ordered
	 */
	protected MethodsType methods;

	/**
	 * The cached value of the '{@link #getCallStacks() <em>Call Stacks</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCallStacks()
	 * @generated
	 * @ordered
	 */
	protected CallStacksType callStacks;

	/**
	 * The cached value of the '{@link #getMergedMethodInvocations() <em>Merged Method Invocations</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMergedMethodInvocations()
	 * @generated
	 * @ordered
	 */
	protected MergedMethodInvocationsType mergedMethodInvocations;

	/**
	 * The cached value of the '{@link #getMergedSqlStatementExecutions() <em>Merged Sql Statement Executions</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMergedSqlStatementExecutions()
	 * @generated
	 * @ordered
	 */
	protected MergedSqlStatementExecutionsType mergedSqlStatementExecutions;

	/**
	 * The cached value of the '{@link #getMergedCallStack() <em>Merged Call Stack</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMergedCallStack()
	 * @generated
	 * @ordered
	 */
	protected ThreadCallStack mergedCallStack;

	/**
	 * The cached value of the '{@link #getRootPackage() <em>Root Package</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRootPackage()
	 * @generated
	 * @ordered
	 */
	protected org.anachronos.jeep.model.trace.Package rootPackage;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TraceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TracePackage.Literals.TRACE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MethodsType getMethods() {
		return methods;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMethods(MethodsType newMethods, NotificationChain msgs) {
		MethodsType oldMethods = methods;
		methods = newMethods;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__METHODS, oldMethods, newMethods);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMethods(MethodsType newMethods) {
		if (newMethods != methods) {
			NotificationChain msgs = null;
			if (methods != null)
				msgs = ((InternalEObject)methods).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__METHODS, null, msgs);
			if (newMethods != null)
				msgs = ((InternalEObject)newMethods).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__METHODS, null, msgs);
			msgs = basicSetMethods(newMethods, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__METHODS, newMethods, newMethods));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CallStacksType getCallStacks() {
		return callStacks;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCallStacks(CallStacksType newCallStacks, NotificationChain msgs) {
		CallStacksType oldCallStacks = callStacks;
		callStacks = newCallStacks;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__CALL_STACKS, oldCallStacks, newCallStacks);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCallStacks(CallStacksType newCallStacks) {
		if (newCallStacks != callStacks) {
			NotificationChain msgs = null;
			if (callStacks != null)
				msgs = ((InternalEObject)callStacks).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__CALL_STACKS, null, msgs);
			if (newCallStacks != null)
				msgs = ((InternalEObject)newCallStacks).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__CALL_STACKS, null, msgs);
			msgs = basicSetCallStacks(newCallStacks, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__CALL_STACKS, newCallStacks, newCallStacks));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MergedMethodInvocationsType getMergedMethodInvocations() {
		return mergedMethodInvocations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMergedMethodInvocations(MergedMethodInvocationsType newMergedMethodInvocations, NotificationChain msgs) {
		MergedMethodInvocationsType oldMergedMethodInvocations = mergedMethodInvocations;
		mergedMethodInvocations = newMergedMethodInvocations;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__MERGED_METHOD_INVOCATIONS, oldMergedMethodInvocations, newMergedMethodInvocations);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMergedMethodInvocations(MergedMethodInvocationsType newMergedMethodInvocations) {
		if (newMergedMethodInvocations != mergedMethodInvocations) {
			NotificationChain msgs = null;
			if (mergedMethodInvocations != null)
				msgs = ((InternalEObject)mergedMethodInvocations).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__MERGED_METHOD_INVOCATIONS, null, msgs);
			if (newMergedMethodInvocations != null)
				msgs = ((InternalEObject)newMergedMethodInvocations).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__MERGED_METHOD_INVOCATIONS, null, msgs);
			msgs = basicSetMergedMethodInvocations(newMergedMethodInvocations, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__MERGED_METHOD_INVOCATIONS, newMergedMethodInvocations, newMergedMethodInvocations));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MergedSqlStatementExecutionsType getMergedSqlStatementExecutions() {
		return mergedSqlStatementExecutions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMergedSqlStatementExecutions(MergedSqlStatementExecutionsType newMergedSqlStatementExecutions, NotificationChain msgs) {
		MergedSqlStatementExecutionsType oldMergedSqlStatementExecutions = mergedSqlStatementExecutions;
		mergedSqlStatementExecutions = newMergedSqlStatementExecutions;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS, oldMergedSqlStatementExecutions, newMergedSqlStatementExecutions);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMergedSqlStatementExecutions(MergedSqlStatementExecutionsType newMergedSqlStatementExecutions) {
		if (newMergedSqlStatementExecutions != mergedSqlStatementExecutions) {
			NotificationChain msgs = null;
			if (mergedSqlStatementExecutions != null)
				msgs = ((InternalEObject)mergedSqlStatementExecutions).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS, null, msgs);
			if (newMergedSqlStatementExecutions != null)
				msgs = ((InternalEObject)newMergedSqlStatementExecutions).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS, null, msgs);
			msgs = basicSetMergedSqlStatementExecutions(newMergedSqlStatementExecutions, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS, newMergedSqlStatementExecutions, newMergedSqlStatementExecutions));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ThreadCallStack getMergedCallStack() {
		return mergedCallStack;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMergedCallStack(ThreadCallStack newMergedCallStack, NotificationChain msgs) {
		ThreadCallStack oldMergedCallStack = mergedCallStack;
		mergedCallStack = newMergedCallStack;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__MERGED_CALL_STACK, oldMergedCallStack, newMergedCallStack);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMergedCallStack(ThreadCallStack newMergedCallStack) {
		if (newMergedCallStack != mergedCallStack) {
			NotificationChain msgs = null;
			if (mergedCallStack != null)
				msgs = ((InternalEObject)mergedCallStack).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__MERGED_CALL_STACK, null, msgs);
			if (newMergedCallStack != null)
				msgs = ((InternalEObject)newMergedCallStack).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__MERGED_CALL_STACK, null, msgs);
			msgs = basicSetMergedCallStack(newMergedCallStack, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__MERGED_CALL_STACK, newMergedCallStack, newMergedCallStack));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public org.anachronos.jeep.model.trace.Package getRootPackage() {
		return rootPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetRootPackage(org.anachronos.jeep.model.trace.Package newRootPackage, NotificationChain msgs) {
		org.anachronos.jeep.model.trace.Package oldRootPackage = rootPackage;
		rootPackage = newRootPackage;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__ROOT_PACKAGE, oldRootPackage, newRootPackage);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRootPackage(org.anachronos.jeep.model.trace.Package newRootPackage) {
		if (newRootPackage != rootPackage) {
			NotificationChain msgs = null;
			if (rootPackage != null)
				msgs = ((InternalEObject)rootPackage).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__ROOT_PACKAGE, null, msgs);
			if (newRootPackage != null)
				msgs = ((InternalEObject)newRootPackage).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TracePackage.TRACE__ROOT_PACKAGE, null, msgs);
			msgs = basicSetRootPackage(newRootPackage, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TracePackage.TRACE__ROOT_PACKAGE, newRootPackage, newRootPackage));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				return basicSetMethods(null, msgs);
			case TracePackage.TRACE__CALL_STACKS:
				return basicSetCallStacks(null, msgs);
			case TracePackage.TRACE__MERGED_METHOD_INVOCATIONS:
				return basicSetMergedMethodInvocations(null, msgs);
			case TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS:
				return basicSetMergedSqlStatementExecutions(null, msgs);
			case TracePackage.TRACE__MERGED_CALL_STACK:
				return basicSetMergedCallStack(null, msgs);
			case TracePackage.TRACE__ROOT_PACKAGE:
				return basicSetRootPackage(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				return getMethods();
			case TracePackage.TRACE__CALL_STACKS:
				return getCallStacks();
			case TracePackage.TRACE__MERGED_METHOD_INVOCATIONS:
				return getMergedMethodInvocations();
			case TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS:
				return getMergedSqlStatementExecutions();
			case TracePackage.TRACE__MERGED_CALL_STACK:
				return getMergedCallStack();
			case TracePackage.TRACE__ROOT_PACKAGE:
				return getRootPackage();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				setMethods((MethodsType)newValue);
				return;
			case TracePackage.TRACE__CALL_STACKS:
				setCallStacks((CallStacksType)newValue);
				return;
			case TracePackage.TRACE__MERGED_METHOD_INVOCATIONS:
				setMergedMethodInvocations((MergedMethodInvocationsType)newValue);
				return;
			case TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS:
				setMergedSqlStatementExecutions((MergedSqlStatementExecutionsType)newValue);
				return;
			case TracePackage.TRACE__MERGED_CALL_STACK:
				setMergedCallStack((ThreadCallStack)newValue);
				return;
			case TracePackage.TRACE__ROOT_PACKAGE:
				setRootPackage((org.anachronos.jeep.model.trace.Package)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				setMethods((MethodsType)null);
				return;
			case TracePackage.TRACE__CALL_STACKS:
				setCallStacks((CallStacksType)null);
				return;
			case TracePackage.TRACE__MERGED_METHOD_INVOCATIONS:
				setMergedMethodInvocations((MergedMethodInvocationsType)null);
				return;
			case TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS:
				setMergedSqlStatementExecutions((MergedSqlStatementExecutionsType)null);
				return;
			case TracePackage.TRACE__MERGED_CALL_STACK:
				setMergedCallStack((ThreadCallStack)null);
				return;
			case TracePackage.TRACE__ROOT_PACKAGE:
				setRootPackage((org.anachronos.jeep.model.trace.Package)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TracePackage.TRACE__METHODS:
				return methods != null;
			case TracePackage.TRACE__CALL_STACKS:
				return callStacks != null;
			case TracePackage.TRACE__MERGED_METHOD_INVOCATIONS:
				return mergedMethodInvocations != null;
			case TracePackage.TRACE__MERGED_SQL_STATEMENT_EXECUTIONS:
				return mergedSqlStatementExecutions != null;
			case TracePackage.TRACE__MERGED_CALL_STACK:
				return mergedCallStack != null;
			case TracePackage.TRACE__ROOT_PACKAGE:
				return rootPackage != null;
		}
		return super.eIsSet(featureID);
	}

} //TraceImpl
